package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F48 AS SI  待授权失败原因
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F48_AS_SI_AuthFailReasonEnum {
    _01("01", "卡号长度校验失败"),
    _02("02", "卡号校验位校验失败"),
    _03("03", "卡有效期校验失败"),
    _04("04", "CVN(CVN2)校验失败"),
    _05("05", "PVN 校验失败"),
    _07("07", "ARQC 校验不通过"),
    _08("08", "TVR&CVR 校验不通过"),
    _09("09", "ICVN 校验不通过"),
    _10("10", "ARPC 生成失败"),
    _11("11", "未通过止付名单检查"),
    _12("12", "超过普通卡单笔交易额度控制"),
    _13("13", "超过普通卡累计交易额度控制"),
    _14("14", "超过 VIP 卡单笔交易额度控制"),
    _15("15", "超过 VIP 卡累计交易额度控制"),
    _16("16", "超过交易总笔数限制"),
    _17("17", "未通过受理地区止付检查"),
    _18("18", "未通过受理商户止付检查"),
    _19("19", "不允许降级交易"),
    _96("96", "系统异常"),
    ;

    private String code;
    private String desc;

    F48_AS_SI_AuthFailReasonEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F48_AS_SI_AuthFailReasonEnum find(String code) {
        F48_AS_SI_AuthFailReasonEnum result = Arrays.stream(F48_AS_SI_AuthFailReasonEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
